Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ObsUX] Add Missing transaction warning if there are Transactions or Spans with a parent.id that doesn't exist in the trace #171196

Conversation

jennypavlova
Copy link
Member

@jennypavlova jennypavlova commented Nov 14, 2023

Closes #25117

Summary

Add a missing transaction warning if there are Transactions or Spans with a parent.id that doesn't exist in the trace.

Testing

  • Use the trace_with_orphan_items.ts scenario: node scripts/synthtrace --clean trace_with_orphan_items.ts
  • In APM -> Traces there are 2 traces:
    • image
  • Check the traces:
    • Incomplete trace (with warning):

      • image
    • Complete trace (no warning):

      • image
  • Unit test in waterfall_helpers.test.ts

@jennypavlova jennypavlova added the Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team label Nov 14, 2023
@jennypavlova jennypavlova self-assigned this Nov 14, 2023
@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@jennypavlova jennypavlova changed the title [ObsUX] Add Missing transaction warning if there are spans without parent id [ObsUX] Add Missing transaction warning if there are Transactions or Spans with a parent.id that doesn't exist in the trace Nov 15, 2023
@jennypavlova jennypavlova force-pushed the 25117-apm-trace-timeline-show-message-when-transactions-are-missing branch from 7096e45 to 45317fa Compare November 16, 2023 10:38
@jennypavlova jennypavlova added release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting labels Nov 16, 2023
@jennypavlova jennypavlova marked this pull request as ready for review November 16, 2023 12:32
@jennypavlova jennypavlova requested a review from a team as a code owner November 16, 2023 12:32
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-infra_services-team (Team:obs-ux-infra_services)

return (
<EuiToolTip
position="left"
delay="regular"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

regular is the default value, so no need to specify this prop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, removed ✅

},
} as WaterfallTransaction;

it('should return false if there is not orphan items', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should return false if there is not orphan items', () => {
it('should return false if there are no orphan items', () => {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot that after I changed item with items, fixed 👍

expect(getHasOrphanTraceItems(traceItems)).toBe(false);
});

it('should return true if there is orphan items', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
it('should return true if there is orphan items', () => {
it('should return true if there are orphan items', () => {

Comment on lines 422 to 430
const waterfallItemsIds = traceDocs.map((doc) =>
doc.processor.event === 'span'
? (doc?.span as WaterfallSpan['span']).id
: doc?.transaction?.id
);

return traceDocs.some(
(item) => item.parent?.id && !waterfallItemsIds.includes(item.parent?.id)
);
Copy link
Contributor

@cauemarcondes cauemarcondes Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The waterfall itself is already very slow, WDYT of this change to speed this function up? With this you change it from O(n) to O(1).

Suggested change
const waterfallItemsIds = traceDocs.map((doc) =>
doc.processor.event === 'span'
? (doc?.span as WaterfallSpan['span']).id
: doc?.transaction?.id
);
return traceDocs.some(
(item) => item.parent?.id && !waterfallItemsIds.includes(item.parent?.id)
);
const waterfallItemsIds = new Set(traceDocs.map((doc) =>
doc.processor.event === 'span'
? (doc?.span as WaterfallSpan['span']).id
: doc?.transaction?.id
));
return traceDocs.some(
(item) => item.parent?.id && !waterfallItemsIds.has(item.parent.id)
);

FYI: I did not test it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice idea, thank you! I changed that and tested it, looks good 👍

@botelastic botelastic bot added the Team:APM All issues that need APM UI Team support label Nov 20, 2023
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:APM)

@jennypavlova jennypavlova requested a review from a team as a code owner November 20, 2023 14:00
Copy link
Contributor

@cauemarcondes cauemarcondes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@kpatticha kpatticha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳 🥳 Thanks for fixing it.

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
apm 1520 1521 +1

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
apm 3.7MB 3.7MB +1.1KB

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @jennypavlova

@jennypavlova jennypavlova merged commit 3dbe1e4 into elastic:main Nov 20, 2023
@jennypavlova jennypavlova deleted the 25117-apm-trace-timeline-show-message-when-transactions-are-missing branch November 20, 2023 16:33
</EuiFlexItem>
{hasOrphanTraceItems ? (
<EuiFlexItem grow={false}>
<MissingTransactionWarning />
Copy link
Member

@sorenlouv sorenlouv Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I suggest naming this OrphanTraceItemsWarning to align with hasOrphanTraceItems

'xpack.apm.transactionDetails.agentMissingTransactionMessage',
{
defaultMessage:
'This trace contains spans from missing transactions. As a result these spans are not displayed in the timeline.',
Copy link
Member

@sorenlouv sorenlouv Nov 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message is not entirely correct afaict. Example: a (parent) span could be missing, meaning that any child spans (or transactions) will not be displayed. So it is not just about missing transactions.
Also, we should suggest work-arounds for the user if possible.

Suggestion for error message:

This trace is incomplete and {{count}} items could not be displayed in the timeline. This could be a temporary problem caused by ingest delay, or a permanent problem caused by some events being dropped.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, I remember I took the message from the issue description, and now that you mentioned that it makes sense. One question regarding the {{count}} - we want to show the missing items in the waterfall based on the items returned and the items shown in the waterfall, right? I guess here we just calculate it, I don't see the missing items count existing somewhere (similar to the check we have here but instead of returning a boolean it should return the missing items count)
image

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a draft PR for those changes so we can better discuss there

Copy link
Member

@sorenlouv sorenlouv Dec 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question regarding the {{count}} - we want to show the missing items in the waterfall based on the items returned and the items shown in the waterfall, right? I guess here we just calculate it, I don't see the missing items count existing somewhere (similar to the check we have here but instead of returning a boolean it should return the missing items count)

Yes, I was thinking it would be beneficial to at least show the number of (orphan) items that cannot be placed because a parent is missing.

If it's difficult to calculate this, let's just skip it for now.

jennypavlova added a commit that referenced this pull request Dec 14, 2023
#173196)

Closes #173134

## Summary

This PR is a follow-up to #171196 and changes the missing trace items
tooltip message.

<img width="1630" alt="image"
src="https://github.com/elastic/kibana/assets/14139027/ae13547c-f2fb-4a19-8062-2774ea782111">

## Testing 
Same as in
#171196 (comment) but the
message should be changed to the one in the screenshot here
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting release_note:skip Skip the PR/issue when compiling release notes Team:APM All issues that need APM UI Team support Team:obs-ux-infra_services Observability Infrastructure & Services User Experience Team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[APM] Trace timeline: Show message when transactions are missing
8 participants